//
//  YunGrideAlert.swift
//  YunChenCalculator
//
//  Created by Li Dong on 2023/10/16.
//

import UIKit

class YunGrideAlert: UIView {

    var contentView: UIView!
    
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var subTitleLabel: UILabel!
    
    var callBack:(() -> Void)?
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        contentView = loadViewFromNib()
        contentView.frame = self.bounds
        addSubview(contentView)
        
        contentView.backgroundColor = .black.withAlphaComponent(0.5)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    @IBAction func closeAlert(_ sender: UIButton) {
        removeFromSuperview()
    }
    
    @IBAction func againHandler(_ sender: Any) {
        removeFromSuperview()
        callBack?()
    }
    
    var title: String! {
        didSet{
            titleLabel.text = title
        }
    }
    
    var subTitle: String! {
        didSet {
            subTitleLabel.text = subTitle
        }
    }
    
}
